/************************************************************************

								Heroes IV
					  Copyright 2002, The 3DO Company

	------------------------------------------------------------------
  						       town_school_skills.cpp

	$Header: $

	$NoKeywords: $

 ************************************************************************/

#include "precompiled.h"
#include "town_school_skills.h"

#include "enum_operations.h"
#include "skill.h"
#include "skill_properties.h"
#include "skill_set.h"
#include "town_type.h"

// --------------------------------------------------------------------------
// Returns the set of skills that could appear in a given town type's 
// school (e.g. University or Seminary)
// --------------------------------------------------------------------------
t_skill_set const & get_possible_town_school_skills( t_town_type town_type )
{
	static t_skill_set empty_set;
	static t_skill_set academy_set; // Life, Order, Death, Nobility, Scouting secondary skills
	static t_skill_set haven_set;   // Nature, Life, Order, Combat, Tactics secondary skills
	static bool initialized = false;

	if ( !initialized )
	{
		initialized = true;

		t_skill_type skill;

		for ( skill = t_skill_type(0); skill < k_skill_count; enum_incr( skill ) )
		{
			if ( is_primary_skill( skill ) )
				continue;

			switch ( get_primary_skill( skill ) )
			{
				case k_skill_life_magic:
				case k_skill_order_magic:
					academy_set[ skill ] = true;
					haven_set[ skill ] = true;
					break;

				case k_skill_combat_defense:
				case k_skill_tactics:
				case k_skill_nature_magic:
					haven_set[ skill ] = true;
					break;

				case k_skill_death_magic:
				case k_skill_nobility:
				case k_skill_scouting:
					academy_set[ skill ] = true;
					break;
			}
		}
	}

	switch( town_type )
	{
		case k_town_life:
			return haven_set;
			
		case k_town_order:
			return academy_set;

		default:
			return empty_set;
	}
}
